<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    体重:
     <input type="number" v-model="wg">
     身高:
     <input type="number" v-model="hg">
     --->
     {{ bmi() }}
     {{ bmi() }}
     {{ bmi() }}
     <br>
     {{bmi2}}
     {{bmi2}}
     {{bmi2}}
  </div>
  <script src="./vue.global.js"></script>
  <script>
    const { createApp } = Vue;
    const app = createApp({
      data(){
        return {
          wg: 90, // 体重kg
          hg: 1.8 // 身高 m
        }
      },
      methods: {
        bmi(){
          console.log('method运行了');
          return (this.wg/(this.hg*this.hg)).toFixed(2)
        }
      },
      computed: {
        bmi2(){
          // 经过计算返回计算的结果即可
          console.log('计算属性运行了');
          return (this.wg/(this.hg*this.hg)).toFixed(2);
        }
      }
    })
    app.mount('#app')
  </script>
</body>
</html>